home *** CD-ROM | disk | FTP | other *** search
- ikbd equ $118 ; keyboard vector
- key_ctl equ $fffffc00 ; keyboard control register
- key_dat equ $fffffc02 ; keyboard data register
-
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
- * Initialise custom keyboard packet handler *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
- Initialise_ikbd:
- lea key_buffer,a0
- moveq #128/4-1,d7
- .clear_keybd:
- clr.l (a0)+
- dbf d7,.clear_keybd
- bsr Flush_ikbd
- move.l ikbd.w,old_ikbd
- move.l #ikbd_handler,ikbd.w
- rts
-
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
- * Remove custom keyboard packet handler *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
- Remove_ikbd:
- bsr Flush_ikbd
- move.l old_ikbd,ikbd.w
- rts
-
- old_ikbd: ds.l 1
-
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
- * Remove unread data from ikbd chip *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
- Flush_ikbd:
- move.b key_ctl.w,d0
- btst #0,d0
- bne.s read
- rts
- read move.b key_dat.w,d0
- bra.s Flush_ikbd
-
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
- * Keyboard Packet handler *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
- ikbd_handler:
- movem.l a0/d0-d1,-(sp)
- move.b key_ctl.w,d0
- btst #7,d0
- beq.s ikbd_aq
- btst #4,d0
- bne.s ik_err
- btst #5,d0
- bne.s ik_err
- btst #6,d0
- bne.s ik_err
- btst #0,d0
- beq.s ik_err
- move.b key_dat.w,d0
-
- cmp.b #$ff,d0 ; joystick 1 packet
- beq.s do_joy1
- cmp.b #$fe,d0 ; joystick 0 packet
- beq.s do_joy0
-
- mouse_event:
- move.b d0,d1
- and.b #$fc,d1 ; %111110xx = mouse packet
- cmp.b #$f8,d1
- bne.s key_press
- and.b #3,d0
- move.b d0,buttons
- move.l #get_dx,ikbd.w
- bra.s ikbd_aq
-
- do_joy0:
- move.l #get_joy0,ikbd.w
- bra.s ikbd_aq
-
- do_joy1:
- move.l #get_joy1,ikbd.w
- bra.s ikbd_aq
-
-
- key_press:
- btst #7,d0 ; test release bit
- seq d1 ; d1.b cleared if release bit set
- and.w #$7f,d0 ; mask off release bit
- lea key_buffer,a0
- move.b d1,(a0,d0.w)
- ikbd_aq:
- bclr #6,$fffffa11.w
- movem.l (sp)+,a0/d0-d1
- rte
-
-
- ik_err: move.b key_dat.w,d0
- bra.s ikbd_aq
-
- get_dx: move.l d0,-(sp)
- move.b key_dat.w,d0
- ext.w d0
- add d0,mouse_dx
- move.l #get_dy,ikbd.w
- move.l (sp)+,d0
- bclr #6,$fffffa11.w
- rte
-
- get_dy: move.l d0,-(sp)
- move.b key_dat.w,d0
- ext.w d0
- add d0,mouse_dy
- move.l #ikbd_handler,ikbd.w
- move.l (sp)+,d0
- bclr #6,$fffffa11.w
- rte
-
-
- get_joy1:
- move.b key_dat.w,joy0
- move.l #ikbd_handler,ikbd.w
- bclr #6,$fffffa11.w
- rte
-
- get_joy0:
- move.b key_dat.w,joy1
- move.l #ikbd_handler,ikbd.w
- bclr #6,$fffffa11.w
- rte
-
- Section Bss
-
- key_buffer: ds.b 128
-
- mouse_dx: ds.w 1
- mouse_dy: ds.w 1
-
- joy0: ds.b 1
- joy1: ds.b 1
- buttons: ds.b 1
-
- Section Text
-